//
//  BCInvitationCodeView.m
//  GSBlockChain
//
//  Created by guoshikeji_a on 2018/11/29.
//  Copyright © 2018 guoshikeji. All rights reserved.
//

#import "BCInvitationCodeView.h"

@interface BCInvitationCodeView ()

@property (nonatomic, strong) QMUITextField *codeTF;

@property (nonatomic, strong) UIImageView *iconImageView;

@end

@implementation BCInvitationCodeView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setupSubviews];
    }
    return self;
}
- (void)setupSubviews {
    self.iconImageView = [UIImageView new];
    self.iconImageView.contentMode = UIViewContentModeScaleAspectFit;
    self.iconImageView.image = LOAD_IMAGE(@"recommend_code");
    [self addSubview:self.iconImageView];
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).offset(12.0);
        make.centerY.mas_equalTo(self);
        make.size.mas_equalTo(CGSizeMake(25.0, 25.0));
    }];
    //
    self.codeTF = [QMUITextField new];
    self.codeTF.textColor = [UIColor qmui_colorWithHexString:@"#333333"];
    self.codeTF.font = [UIFont systemFontOfSize:18 weight:UIFontWeightRegular];
    self.codeTF.placeholderColor = [UIColor qmui_colorWithHexString:@"#D9D9D9"];
    [self addSubview:self.codeTF];
    [self.codeTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.iconImageView.mas_right).offset(15.0);
        make.centerY.mas_equalTo(self);
        make.height.mas_equalTo(self);
        make.right.mas_equalTo(self).offset(-15.0);
    }];
    self.codeTF.placeholder = GSLoginLocalized(@"Invitation code");
    self.codeTF.inputAccessoryView = [UIView new];
    self.codeTF.autocorrectionType = UITextAutocorrectionTypeNo;
    self.codeTF.autocapitalizationType = UITextAutocapitalizationTypeNone;
    //
    UIView *bottomLine = [UIView new];
    bottomLine.backgroundColor = [UIColor qmui_colorWithHexString:@"#F3F3F3"];
    [self addSubview:bottomLine];
    [bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self).offset(11.0);
        make.bottom.right.mas_equalTo(self);
        make.height.mas_equalTo(1);
    }];
}

- (NSString *)code {
    return self.codeTF.text;
}


+ (CGFloat)defaultHeight {
    return 55.0f;
}


@end
